package com.yylending.las.personal.bandcard.supportbank;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.Loader;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yyfax.common.tools.DensityUtil;
import com.yyfax.infrastructure.mvp.Presenter;
import com.yylending.las.R;
import com.yylending.las.base.BaseFragment;
import com.yylending.las.common.widgets.CustomGridLayoutManager;
import com.yylending.las.common.widgets.Divider;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by ying_he on 2017/6/14.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class SupportBankListFragment extends BaseFragment {

    @BindView(R.id.support_bank_rv)
    RecyclerView mSupportBankRv;
    private Unbinder unbinder;
    private SupportBankListAdapter mAdapter;

    public static BaseFragment newInstance() {
        BaseFragment fragment = new SupportBankListFragment();
        //mBankInfo = bankInfo;
//        Bundle args = new Bundle();
//        args.putInt(ARG_SECTION_NUMBER, sectionNumber);
//        args.putParcelable(ARG_BANK_INFO, bankInfo);
//        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_support_bank, null);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initData();
    }

    private void initData() {
        CustomGridLayoutManager LayoutManager = new CustomGridLayoutManager(getActivity(), 1);
        mSupportBankRv.setLayoutManager(LayoutManager);
        mAdapter = new SupportBankListAdapter();
        mSupportBankRv.addItemDecoration(new Divider(DensityUtil.dip2px(getActivity(), 0.5f), getResources().getColor(R.color.color_f1f3f7), false,
                0, 0, 0, DensityUtil.dip2px(getActivity(), 0.5f)));
        mSupportBankRv.setAdapter(mAdapter);
    }

    @Override
    public void onLoadFinished(Loader<Presenter> loader, Presenter data, int placeholder) {

    }

    @Override
    public Loader<Presenter> onCreateLoader(int id, Bundle args) {
        return null;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
